//
//  NSObjectCustomPropertyDefine.h
//  vidpioneer
//
//  Created by ricky on 15/8/3.
//  Copyright (c) 2015年 tencent. All rights reserved.
//

#ifndef vidpioneer_NSObjectCustomPropertyDefine_h
#define vidpioneer_NSObjectCustomPropertyDefine_h

#import "NSObject+AssociativeObject.h"

#define CustomAccessor(accessor, type, key) \
- (type)accessor \
{ \
    return (type)[self associativeObjectForKey:key];\
}

#define CustomMutator(mutator, type, key) \
- (void)mutator :(type)value \
{ \
    if (!value) {\
        [self removeAssociatedObjectForKey:key];\
    } else {\
        [self setAssociativeObject:value forKey:key];\
    }\
}

#define CUSTOM_PROPERTY(accessor, mutator, type) \
    CustomAccessor (accessor, type, @#accessor) \
    CustomMutator (mutator, type, @#accessor)

#endif
